package chapter02;

import java.util.Scanner;

public class ShopingMarket {
    public static void main(String[] args) {
        // TODO: 1. 定义五个商品价格
        // TODO: 2. 输出商品目录

        // TODO: 3. 补充相关变量
        double toothbrush=8.8;
        double towel=10.0;
        double cup=18.8;
        double apple=12.5;
        double banana=15.5;
        int i=0;
        String a = "Y";// 定义字符类型变量
        System.out.println("-------黑马小商场------");
        System.out.println("1.牙刷的价格为:"+toothbrush+"元");
        System.out.println("2.毛巾的价格为:"+towel+"元");
        System.out.println("3.水杯的价格为:"+cup+"元");
        System.out.println("4.苹果的价格为:"+apple+"元");
        System.out.println("5.香蕉的价格为:"+banana+"元");
        // Scanner 无法获取char类型数据
        while (a.equals("y")){// String类型字符串无法使用 == 判断是否相等 xuanZe == "Y"
            // TODO 4.进行条件判断 获取用户选择的商品和数量 计算总消费
            Scanner sc1 = new Scanner(System.in);
            System.out.println("请输入你需要购买商品的序列号:");
            i=sc1.nextInt();
            switch(i){
                case 1:
                    System.out.println("请输入你需要购买牙刷的数量:");
                    int toothbrushnnumber=sc1.nextInt();
                    double toothbrushnnum=toothbrushnnumber*toothbrush;
                    System.out.println("你购买了牙刷"+toothbrushnnumber+
                            "支,需要花费"+toothbrushnnum+"元");
                    System.out.println("需要继续购买请输入Y,否则输入N");
                    a=sc1.next();
                    break;
                case 2:
                    System.out.println("请输入你需要购买毛巾的数量:");
                    int towelnumber=sc1.nextInt();
                    double towelnum=towelnumber*towel;
                    System.out.println("你购买了毛巾"+towelnumber+"个,需要" +
                            "花费"+towelnum+"元");
                    System.out.println("需要继续购买请输入Y,否则输入N");
                    a=sc1.next();
                    break;
                case 3:
                    System.out.println("请输入你需要购买水杯的数量:");
                    int cupnumber=sc1.nextInt();
                    double cupnum=cupnumber*cup;
                    System.out.println("你购买了水杯"+cupnumber+"个,需要花" +
                            "费"+cupnum+"元");
                    System.out.println("需要继续购买请输入Y,否则输入N");
                    a=sc1.next();
                    break;
                case 4:
                    System.out.println("请输入你需要购买苹果的数量:");
                    int applenumber=sc1.nextInt();
                    double applenum=applenumber*apple;
                    System.out.println("你购买了苹果"+applenumber+"斤,需要花" +
                            "费"+applenum+"元");
                    System.out.println("需要继续购买请输入Y,否则输入N");
                    a=sc1.next();
                    break;
                case 5:
                    System.out.println("请输入你需要购买香蕉的数量:");
                    int banananumber=sc1.nextInt();
                    double banananum=banananumber*apple;
                    System.out.println("你购买了香蕉"+banananumber+"斤,需要花" +
                            "费"+banananum+"元");
                    System.out.println("需要继续购买请输入Y,否则输入N");
                    a=sc1.next();
                    break;
            }
        }
        System.out.println("期待您的下次光临!");
    }
}
